/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package MuleGame;
package MuleGUI;

import javax.swing.*;
import MuleBackend.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * This GUI will take in number of players, difficulty
 * level, map type, and number of rounds.
 * These information will be sent to Game class
 * where they will be stored inside their respected
 * variable names
 * This GUI display when start or restart menu is 
 * clicked in board GUIs.
 * This GUI will open NameGUI when the OK button is 
 * clicked.
 */
public class StartGUI extends javax.swing.JFrame {

    /**
     * Creates new form StartGUI
     */
    public StartGUI() {
        initComponents();
    }
    
    public String getDiff(String difStr){
    	if(difStr.equals("Easy"))			
    		return "Easy";
		else if(difStr.equals("Medium"))
			return "Medium";
		else
			return "Difficult";
    }


    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        playersLabel = new javax.swing.JLabel();
        difficultyLabel = new javax.swing.JLabel();
        playerComboBox = new javax.swing.JComboBox();
        difficultyComboBox = new javax.swing.JComboBox();
        startButton = new javax.swing.JButton();
        startButton.addMouseListener(new MouseAdapter() {
        	@Override
        	public void mouseClicked(MouseEvent e) {
        		int numPlayers = Integer.parseInt((String)playerComboBox.getSelectedItem());            	 
       		 	String difficulty = getDiff((String)difficultyComboBox.getSelectedItem());
       		 	int mapNum = Integer.parseInt((String)mapComboBox.getSelectedItem());
       		 	int rounds = Integer.parseInt((String)roundComboBox.getSelectedItem());
       		 	dispose();
       		 	
       		 	GameDriver.game.setNumPlayers(numPlayers);
       		 	GameDriver.game.setDifficulty(difficulty);
       		 	GameDriver.game.setMapNum(mapNum);
       		 	GameDriver.game.setRounds(rounds);
       		 	GameDriver.game.setMapNum(mapNum);
       		 	GameDriver.game.generateMap(mapNum);
       		 	
       		 	
       		 	new NameGUI(numPlayers).setVisible(true);
        	}
        });
        cancelButton = new javax.swing.JButton();
        mapLabel = new javax.swing.JLabel();
        mapComboBox = new javax.swing.JComboBox();
        roundLabel = new javax.swing.JLabel();
        roundComboBox = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Start Window (start GUI)");

        playersLabel.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
        playersLabel.setText("Players");

        difficultyLabel.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
        difficultyLabel.setText("Difficulty");

        playerComboBox.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        playerComboBox.setModel(new DefaultComboBoxModel(new String[] {"2", "3", "4"}));

        difficultyComboBox.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        difficultyComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Easy", "Medium", "Difficult" }));

        startButton.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        startButton.setText("Start");

        cancelButton.setFont(new java.awt.Font("Tahoma", 2, 18)); // NOI18N
        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        mapLabel.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
        mapLabel.setText("Map");

        mapComboBox.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        mapComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2" }));

        roundLabel.setFont(new java.awt.Font("Times New Roman", 0, 24)); // NOI18N
        roundLabel.setText("Rounds");

        roundComboBox.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        roundComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "6", "8", "10", "12" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(roundLabel)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(startButton)
                                .addGap(32, 32, 32)
                                .addComponent(cancelButton))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(mapLabel)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(37, 37, 37)
                                    .addComponent(difficultyLabel))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(playersLabel))))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(playerComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(difficultyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(mapComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(roundComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(41, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(playersLabel)
                    .addComponent(playerComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(difficultyComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(difficultyLabel))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(mapComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mapLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(roundLabel)
                    .addComponent(roundComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(startButton)
                    .addComponent(cancelButton))
                .addGap(38, 38, 38))
        );

        mapLabel.getAccessibleContext().setAccessibleName("");

        setSize(new java.awt.Dimension(300, 312));
        setLocationRelativeTo(null);
    }// </editor-fold>                        

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        setVisible(false);
    }                                        

    // Variables declaration - do not modify                     
    private javax.swing.JButton startButton;
    private javax.swing.JButton cancelButton;
    private javax.swing.JComboBox playerComboBox;
    private javax.swing.JComboBox difficultyComboBox;
    private javax.swing.JComboBox mapComboBox;
    private javax.swing.JComboBox roundComboBox;
    private javax.swing.JLabel playersLabel;
    private javax.swing.JLabel difficultyLabel;
    private javax.swing.JLabel mapLabel;
    private javax.swing.JLabel roundLabel;
    // End of variables declaration                   
}